package info.webest.media.files;

import java.io.File;
import java.io.FilenameFilter;

import android.annotation.SuppressLint;

public class FileFilter {

	@SuppressLint("DefaultLocale")
	public static boolean isImageExt(String name) {
		return name.toLowerCase().endsWith(".jpg") || //
				name.toLowerCase().endsWith(".png") || //
				name.toLowerCase().endsWith(".bmp") || //
				name.endsWith(".gif");
	}

	@SuppressLint("DefaultLocale")
	public static boolean isAudioExt(String name) {
		return name.toLowerCase().endsWith(".mp3") || //
				name.toLowerCase().endsWith(".m4a") || //
				name.toLowerCase().endsWith(".m4b") || //
				name.toLowerCase().endsWith(".m4p") || //
				name.toLowerCase().endsWith(".aac") || //
				name.toLowerCase().endsWith(".wav") || //				
				name.endsWith(".ogg");
	}

	@SuppressLint("DefaultLocale")
	public static boolean isVideoExt(String name) {
		return name.toLowerCase().endsWith(".avi") || //
				name.toLowerCase().endsWith(".wmv") || //
				name.toLowerCase().endsWith(".3gp") || //
				name.toLowerCase().endsWith(".mp4");
	}

	@SuppressLint("DefaultLocale")
	public static boolean isBookExt(String name) {
		return name.toLowerCase().endsWith(".fb2") || //
				name.toLowerCase().endsWith(".pdf") || //
				name.toLowerCase().endsWith(".djvu") || //
				name.toLowerCase().endsWith(".epub");
	}

	static class ImageFilter implements FilenameFilter {

		public boolean accept(File item, String name) {

			//boolean is_dir = item.isDirectory();
			//boolean is_file = item.isFile();
			// boolean is_ext = FileFilter.isImageExt(name) ||
			// FileFilter.isAudioExt(name)
			// || FileFilter.isVideoExt(name) || FileFilter.isBookExt(name);
			return  FileFilter.isImageExt(name);
		}
	}

}
